﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using pos.entity;
using NHibernate.Criterion;
namespace idea.tools
{
    
    
    class CommodityClassUtil
    {
        
        public static void initCommodityClass1(ComboBox commodityClass1)
        {
            t_class1 t = new t_class1();
            /// DataSet set = t.query("", "order by name");

            commodityClass1.DropDownStyle = ComboBoxStyle.DropDownList;
            commodityClass1.DataSource = t.List(t.DC.AddOrder(Order.Asc("name")));
            commodityClass1.DisplayMember = "name";
            commodityClass1.ValueMember = "seqID";
        }

        public static void initCommodityClass2(ComboBox commodityClass1,ComboBox commodityClass2)
        {
            t_class2 t = new t_class2();
            long id = Convert.ToInt64(commodityClass1.SelectedValue);
            //     DataSet set = t.query(string.Format("where parentSeqID={0}", id), "order by name");
            try
            {
                commodityClass2.DropDownStyle = ComboBoxStyle.DropDownList;
                commodityClass2.DataSource = t.List(t.DC.Add(Restrictions.Eq("parentSeqID", id)).AddOrder(Order.Asc("name")));
                commodityClass2.DisplayMember = "name";
                commodityClass2.ValueMember = "seqID";
            }
            catch
            {
            }
        }
        public static void initCommodityClass3(ComboBox commodityClass2,ComboBox commodityClass3)
        {
            t_class3 t = new t_class3();
            long id = Convert.ToInt64(commodityClass2.SelectedValue);
            //  DataSet set = t.query(string.Format("where parentSeqID={0}", id), "order by name");
            try
            {
                commodityClass3.DropDownStyle = ComboBoxStyle.DropDownList;
                commodityClass3.DataSource = t.List(t.DC.Add(Restrictions.Eq("parentSeqID", id)).AddOrder(Order.Asc("name")));
                commodityClass3.DisplayMember = "name";
                commodityClass3.ValueMember = "seqID";
            }
            catch
            {
            }
        }
    }
}
